import { createWebHashHistory, createRouter, RouteRecordRaw } from 'vue-router'

import layout from '@/layout/index.vue'
const routes: RouteRecordRaw[] = [
    {
        path: '/',
        component: layout,
        children: [
            {
                path: '/home',
                meta: {
                    title: '主页',
                },
                component: () => import('@/views/home/index.vue'),
            },
            {
                path: '/screen',
                meta: {
                    title: 'VR全景',
                },
                component: () => import('@/views/screen/index.vue'),
            },
        ],
    },
]

const router = createRouter({
    history: createWebHashHistory(),
    routes,
})
router.beforeEach((to, from, next) => {
    document.title = to.meta.title as string
    next()
})

export default router
